<?php

namespace App\Models\Operation;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Topbar
 * @package App\Models\Operation
 * @version June 28, 2018, 11:42 am CST
 *
 * @property string name
 * @property string title
 * @property string description
 * @property string ui
 * @property string css
 */
class TopbarArea extends Model
{
    use SoftDeletes;

    public $table = 'topbar_areas';

    protected $dates = ['deleted_at'];

    public $fillable = [
        'topbar_id',
        'layout',
        'component',
        'onfocus',
        'onclick',
        'editable',
    ];
    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'layout'    => 'string',
        'component' => 'string',
        'onfocus'   => 'string',
        'onclick'   => 'string',
        'editable'  => 'string',

    ];
    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'css' => 'max:50',
    ];

    /**
     * 【关联布局】
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function topbar()
    {
        return $this->hasOne(\App\Models\Operation\Topbar::class, 'id', 'topbar_id');
    }
}
